<!DOCTYPE html>
<html xmlns:th="https://www.thymeleaf.org/">
	<head>
		<meta charset="utf-8">
		<title>药品采购单</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<link rel="stylesheet" th:href="@{/layuiadmin/layui/css/layui.css}" media="all">
	</head>
	<body>
		<!-- 相对于from表单 -->
		<div class="layui-form layui-form-pane" lay-filter="form-layfilter-drugstock" id="form-layfilter-drugstock" style="padding: 10px 10px 0 10px;">
			<div class="layui-form-item" th:hidden="true">
				<label class="layui-form-label">编号</label>
				<div class="layui-input-inline">
					<input type="text" name="ds_id" th:value="${po!=null?po.ds_id:''}" readonly="readonly" placeholder="不可自定义"
					 autocomplete="off" class="layui-input layui-disabled">
				</div>
			</div>
			
			<div class="layui-form-item">
				<label class="layui-form-label">药品</label>
				<div class="layui-input-block" style="width: 500px;">
					<select name="ds_drugid" lay-verify="required">
						<option value="">未选择</option>
						<option th:each="drug:${drugs}" th:value="${drug.drugDict_id}" th:selected="${po!=null?drug.drugDict_id==po.ds_drugid:false}">[[${drug.drugDict_name}]]</option>
					</select>
				</div>
			</div>
			
			<div class="layui-form-item">
				<label class="layui-form-label">数量</label>
				<div class="layui-input-inline">
					<input type="text" name="ds_num" th:value="${po!=null ? po.ds_num : ''}" lay-verify="gtZero" placeholder="请输入同批次购入数量"
					 autocomplete="off" class="layui-input">
				</div>
				<label class="layui-form-label">单价</label>
				<div class="layui-input-inline">
					<input type="text" name="ds_price" th:value="${po!=null ? po.ds_price : ''}" lay-verify="gtZeroPointZero1" placeholder="请输入同批次购入单价(元)"
					 autocomplete="off" class="layui-input">
				</div>
			</div>
			
			<div class="layui-form-item">
				<label class="layui-form-label">总价</label>
				<div class="layui-input-inline">
					<input type="text" name="" th:value="${po!=null ? po.ds_totalmoney : ''}" placeholder="可不填"
					 autocomplete="off" class="layui-input">
				</div>
				<label class="layui-form-label">到货时间</label>
				<div class="layui-input-inline">
					<input type="text" name="ds_arrivaltime" th:value="${po!=null ? #dates.format(po.ds_arrivaltime,'yyyy-MM-dd HH:mm:ss') : ''}" id="ds_arrivaltime" lay-verify="required" placeholder="必填"
					 class="layui-input">
				</div>
			</div>
			
			<div class="layui-form-item">
				<label class="layui-form-label">药品批次</label>
				<div class="layui-input-inline">
					<input type="text" name="ds_batch" th:value="${po!=null ? po.ds_batch : ''}" lay-verify="required" placeholder="必填" autocomplete="off"
					 class="layui-input">
				</div>
				<label class="layui-form-label">药品批号</label>
				<div class="layui-input-inline">
					<input type="text" name="ds_batchnum" th:value="${po!=null ? po.ds_batchnum : ''}" lay-verify="required" placeholder="必填" autocomplete="off"
					 class="layui-input">
				</div>
			</div>
			
			<div class="layui-form-item">
				<label class="layui-form-label">生产日期</label>
				<div class="layui-input-inline">
					<input type="text" name="ds_startdate" th:value="${po!=null ? #dates.format(po.ds_startdate,'yyyy-MM-dd') : ''}" id="ds_startdate"
					  lay-verify="date" placeholder="必填" class="layui-input">
				</div>
				<div th:hidden="${po==null?true:false}">
					<label class="layui-form-label">有效日期</label>
					<div class="layui-input-inline">
						<input type="text" name="ds_enddate" th:value="${po!=null ? #dates.format(po.ds_enddate,'yyyy-MM-dd') : ''}" id="ds_enddate"
						  disabled="disabled" placeholder="必填" class="layui-input layui-disabled">
					</div>
				</div>
			</div>
			
			<div class="layui-form-item">
				<label class="layui-form-label">有效期(月)</label>
				<div class="layui-input-inline">
					<input type="text" name="ds_effectivetime" th:value="${po!=null ? po.ds_effectivetime : ''}" lay-verify="gtZero" placeholder="必填"
					 autocomplete="off" class="layui-input">
				</div>
				<label class="layui-form-label">产地</label>
				<div class="layui-input-inline">
					<input type="text" name="ds_production" th:value="${po!=null ? po.ds_production : ''}" lay-verify="required" placeholder="必填"
					 autocomplete="off" class="layui-input">
				</div>
			</div>
			
			<div class="layui-form-item">
				<label class="layui-form-label">说明</label>
				<div class="layui-input-inline">
					<input type="text" name="ds_remark" th:value="${po!=null ? po.ds_remark : ''}" placeholder="可选"
					 autocomplete="off" class="layui-input" style="width: 500px;">
				</div>
			</div>
			
			<div class="layui-form-item">
				<label class="layui-form-label">订单号</label>
				<div class="layui-input-inline">
					<input type="text" name="ds_order" th:value="${po!=null ? po.ds_order : ''}" lay-verify="required" placeholder="必填"
					 autocomplete="off" class="layui-input">
				</div>
				<div th:hidden="${po==null?true:false}">
					<label class="layui-form-label" >订单状态</label>
					<div class="layui-input-inline" th:hidden="${po==null?true:false}">
						<input type="text" name="ds_state" th:value="${po!=null ? po.ds_state : ''}" readonly="readonly" placeholder="不可自定义" autocomplete="off"
						 class="layui-input layui-disabled">
					</div>
				</div>
			</div>
			
			<div class="layui-form-item">
				<label class="layui-form-label">验收人</label>
				<div class="layui-input-inline">
					<select name="ds_confirmid" lay-verify="required">
						<option value="">未选择</option>
						<option th:each="user:${users}" th:value="${user.user_id}" th:selected="${po!=null&&po.ds_confirmid==user.user_id ? true : false}">[[${user.realname}]]</option>
					</select>
				</div>
				<div th:hidden="${po==null||po.ds_completetime==null?true:false}">
					<label class="layui-form-label">完成时间</label>
					<div class="layui-input-inline">
						<input type="text" name="ds_completetime" th:value="${po!=null ? #dates.format(po.ds_completetime,'yyyy-MM-dd HH:mm:ss') : ''}" id="ds_completetime" readonly="readonly" placeholder="不可自定义"
						 class="layui-input layui-disabled">
					</div>
				</div>
			</div>
			
			<div class="layui-form-item">
				<label class="layui-form-label">设置采购单</label>
			</div>
			<div class="layui-form-item" th:hidden="${po==null||po.ds_dp_id==null?true:false}"><!-- 没有旧采购单时，隐藏 -->
				<label class="layui-form-label">旧采购单</label>
				<div class="layui-input-block">
					<select name="ds_old_dp_id" disabled="disabled">
						<option value="">不可自定义</option>
						<option th:each="dp:${purchased}" th:value="${dp.dp_id}" th:selected="${po!=null&&po.ds_dp_id!=null&&po.ds_dp_id==dp.dp_id ? true : false}">
[[${dp.dp_id}]]-[[${#dates.format(dp.dp_createtime,'yyyy-MM-dd HH:mm:ss')}]]---[[${dp.drug.drugDict_name}]]---预计数量:[[${dp.dp_num}]]---预计单价:[[${dp.dp_price}]]---[[${dp.dp_state}]]
						</option>
					</select>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">目标采购单</label><!-- lay-verify="required" -->
				<div class="layui-input-block">
					<select name="ds_dp_id" id="ds_dp_id" data-th-lay-verify="${po==null||po.ds_dp_id==null?'required':''}">
						<option value="">未选择</option>
						<option th:each="dp:${purchasing}" th:value="${dp.dp_id}">
[[${dp.dp_id}]]-[[${#dates.format(dp.dp_createtime,'yyyy-MM-dd HH:mm:ss')}]]---[[${dp.drug.drugDict_name}]]---预计数量:[[${dp.dp_num}]]---预计单价:[[${dp.dp_price}]]---[[${dp.dp_state}]]
						</option>
					</select>
				</div>
			</div>
			
			<!-- 不知道有什么用 -->
			<div class="layui-form-item layui-hide">
				<button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
				<input type="button" lay-submit lay-filter="LAY-drugstock-front-submit" id="LAY-drugstock-front-submit" value="确认">
			</div>
		</div>
		<!-- 引入layui框架 -->
		<script th:src="@{/layuiadmin/layui/layui.js}"></script>
		<!-- 引入公共layui代码 -->
		<script type="text/javascript" th:src="@{/public/warehouse/publicsetting.js}"></script>
		<script>
			//启动layui语法：config全局配置
			layui.config({
				base: '[[@{/layuiadmin/}]]' //静态资源所在路径
			}).extend({
				index: 'lib/index' //主入口模块
			}).use(['index', 'form', 'upload','laydate'], function() {//启用哪些组件
				//生成标签的对应对象
				var $ = layui.$,
					form = layui.form,
					upload = layui.upload;
				//不知道是什么
				upload.render({
					elem: '#layuiadmin-upload-useradmin',
					url: layui.setter.base + 'json/upload/demo.js',
					accept: 'images',
					method: 'get',
					acceptMime: 'image/*',
					done: function(res) {
						$(this.item).prev("div").children("input").val(res.data.src)
					}
				});
				
				//启动绑定时间组件
				var laydate = layui.laydate;
				laydate.render({
					elem: "#ds_startdate", //指定元素
					format: 'yyyy-MM-dd',//自定义格式
				});
				laydate.render({
					elem: "#ds_arrivaltime", //指定元素
					type: "datetime",//指定类型
				});
				
			})
		</script>
	</body>
</html>
